<#macro sign value="true">
	<img src="../../images/${value}.png" alt="${value}"/>
</#macro>

<#macro listEvents events registry title="">
	<div class="grid_12 title">
		<h3><strong>${title}</strong></h3>
	</div>
	<div class="clear"></div>
	<#list events?chunk(3) as chunk>
		<#list chunk as event>
			<div class="grid_4 views">
				<h5>${event.name}</h5>
				Type:<em>${event.type?default('')}</em><br/>
				Path:<em>${event.path?default('')}</em><br/>
				Invoke:<em><@godt.eventLink registry=registry event=event /></em><br/>
				Global Transaction:<@godt.sign value=event.globalTransaction?default('true')/>
			</div>
		</#list>
		<div class="clear"></div>
	</#list>
	<div class="clear"></div>
</#macro>
<#macro link component anchor text=anchor>
	<a href="../../${component.parent.baseDir}/${component.parent.module}/${component.parent.name?replace(" ","")}.html#${anchor}"
		>${text}</a>
</#macro>

<#macro eventLink registry event text="">
	<#if event.invoke?exists>
		<#if event.type=="service">
			<#assign component=registry.services[event.invoke]?default('')/>
			<#if component!="">	
				<a href="../../${component.parent.baseDir}/${component.parent.module}/${component.parent.name?replace(" ","")}.html#${event.invoke}"
				>${event.invoke}</a>
			<#else>
			${event.invoke} <!-- Event not found in services -->
			</#if>
		<#else>
			${event.invoke} <!-- Event type: ${event.type} -->
		</#if>
	</#if>
</#macro>

<#macro entityFields entity>
	<#list entity.fields as field>
		<tr>
			<td>&nbsp;</td>
			<td><a name="${entity.entityName}_${field.name}"></a>${field.name}</td>
			<td>${field.colName}</td>
			<td>${field.type}</td>
			<td>${field.description}</td>
			<td><@godt.sign value=field.encrypt?default('false')/></td>
			<td><@godt.sign value=field.enableAuditLog?default('false')/></td>
			<td><@godt.sign value=field.notNull?default('false')/></td>
			<#if field.validates?size gt 0>
				<td>
					<ul>
						<#list field.validates as validate>
							<li>${validate}</li>
						</#list>
					</ul>
				</td>
			<#else>
				<td>&nbsp;</td>
			</#if>
		</tr>
	</#list>
</#macro>

<#macro displayComplex complex>
	<table>
		<tr>
			<th>Entity Alias</th>
			<th>Field</th>
			<th>Default Value</th>
			<th>Function</th>
		</tr>
		<tr>
			<td colspan="4" style="text-align: left">${complex.operator}</td>
		</tr>
		<#list complex.complexAliasFields as field>
			<tr>
				<td>${field.entityAlias}</td>
				<td>${field.field}</td>
				<td>${field.defaultValue}</td>
				<td>${field.function}</td> 
			</tr>
		</#list>
		<#list complex.complexAliases as alias>
			<tr>
				<@displayComplex alias/> 
			</tr>
		</#list>
	</table>
</#macro>